package com.gexin.controller.system.user;

import com.gexin.core.JfinalConfig;
import com.gexin.core.web.SystemBaseController;
import com.gexin.model.system.AdminConfig;
import com.jfinal.ext.route.ControllerBind;

@ControllerBind(controllerKey = "/system/config", viewPath = "WEB-INF/system/admin/")
public class SystemConfigController extends SystemBaseController {

	// 系统配置页
	public void index() {
		AdminConfig config=AdminConfig.dao.findFirst(" select * from t_admin_config ");
		setAttr("config", config);
		render("cofig_edit.html");
	}

	public void query() {
		AdminConfig config=AdminConfig.dao.findFirst(" select * from t_admin_config ");
		renderJson(config);
	}

	/**
	 * 添加或者保存
	 */
	public void addOrUpd() {
		AdminConfig config = getModel(AdminConfig.class, "config");
		if (config.getId()==null) {
			config.save();
		}else {
			config.update();
		}
		JfinalConfig.initBettlShareVars();
		success();
	}
}
